///////////////////////////////////////////////////////////////////////////////
//
// Licensed under the MIT License
//
// Copyright (c) 2010 Chris Colinsky
// All Rights Reserved
//
// version	0.5
// http://code.google.com/p/sugarcookie/
// http://code.google.com/p/sugarcookie/wiki/License
//
////////////////////////////////////////////////////////////////////////////////

package sugarcookie.browser {
	import flash.external.ExternalInterface;
	
	import mx.logging.ILogger;
	import mx.logging.Log;
	
	public class Bookmark {
		private static var _log:ILogger;
		
		public static function createBookmark(title:String,url:String,useAlert:Boolean=false,alertCopy:String=""):Object {
			if (!_log) _log = Log.getLogger("sugarcookie.browser.Bookmark");
			
			if (ExternalInterface.available) {
				var value:Object = ExternalInterface.call("createBookmark",title,url,useAlert,alertCopy);
				if (value as Boolean == true) {
					return {status:true,keyCommand:null};
				} else {
					return {status:false,keyCommand:String(value)};
				}
			} else {
				_log.error("ExternalInterface is not available!");
			}
			
			return null;
		}
	}
}